package com.xywang.service.bill;

import com.xywang.dao.bill.BillDao;
import com.xywang.pojo.Bill;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class BillServiceImpl implements BillService{
    private BillDao billDaoImpl;
    @Autowired
    public void setBillDaoImpl(BillDao billDaoImpl) {
        this.billDaoImpl = billDaoImpl;
    }

    @Override
    public List<Bill> getBillList(String queryProductName,String queryProviderId ,String queryIsPayment, int currentPageNo, int pageSize) {
        currentPageNo = (currentPageNo - 1) * pageSize;
        return billDaoImpl.getBillList(queryProductName,queryProviderId ,queryIsPayment,currentPageNo,pageSize);
    }

    @Override
    public int getBillCountService(Bill bill) {
        return billDaoImpl.getBillCount(bill);
    }

    @Override
    public boolean add(Bill bill) {
        boolean flag = false;
        int i = billDaoImpl.addBill(bill);
        if(i>0){
            flag = true;
        }else{
            System.out.println("BillServiceImpl->add->错误");
        }
        return flag;
    }

    @Override
    public boolean deleteBillById(int delId) {
        boolean flag = false;
        int i = billDaoImpl.deleteBill(delId);
        if(i>0){
            flag = true;
        }else{
            System.out.println("BillServiceImpl->deleteBillById->错误");
        }
        return flag;
    }

    @Override
    public Bill getBillByIdService(int bid) {
        return billDaoImpl.getBillById(bid);
    }

    @Override
    public boolean modify(Bill bill) {
        boolean flag = false;
        int i = billDaoImpl.modify(bill);
        if(i>0){
            flag = true;
        }else{
            System.out.println("BillServiceImpl->modify->错误");
        }
        return flag;
    }
}
